package edu.pitt.dbmi.odie.gapp.gwt.client.filter;

import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.FieldType;

public class ODIE_ClsDS extends DataSource {

    private static ODIE_ClsDS instance = null;
    
    public static ODIE_ClsDS getInstance() {
        if (instance == null) {
          instance = new ODIE_ClsDS("clsDS_XML");
        }
        return instance;
    }
    
    public ODIE_ClsDS(String id) {
        setID(id);
        setDataFormat(DSDataFormat.XML);
        setRecordXPath("/payLoad/clses/cls");
        DataSourceField odieIdField = new DataSourceField("id", FieldType.TEXT, "id");
        odieIdField.setPrimaryKey(true) ;
        DataSourceField odieAnalysisIdField = new DataSourceField("odieAnalysisId", FieldType.TEXT, "aid");
        DataSourceField clsNameField = new DataSourceField("clsName", FieldType.TEXT, "Cls");
        DataSourceField ontologyNameField = new DataSourceField("ontologyName", FieldType.TEXT, "Ont");
        DataSourceField cuiField = new DataSourceField("cui", FieldType.TEXT, "Cui");
        DataSourceField colorField = new DataSourceField("color", FieldType.TEXT, "Color");
        colorField.setLength(14) ;

        odieIdField.setHidden(true) ;
        odieAnalysisIdField.setHidden(true) ;
        cuiField.setHidden(true) ;
        
        setFields(odieIdField, odieAnalysisIdField, clsNameField, ontologyNameField, cuiField, colorField);
        setDataURL("odie_client/snapshot?category=cls");
//        setDataURL("data/dataIntegration/xml/colors_example.xml");
//        setClientOnly(true) ;  
    }
    
	protected Object transformRequest(DSRequest dsRequest) {
		return super.transformRequest(dsRequest);
	}

}
